package cn.tedu.spring_security.service;

import cn.tedu.spring_security.dao.UserDao;
import cn.tedu.spring_security.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    @Override
    public User getByUsername(String username) {
        User user = userDao.findUserByUsername(username);
        return user;
    }

    @Override
    @PostAuthorize("hasRole('ADMIN')")
    public List<User> findAll() {
        List<User> list = userDao.findAll();
        return list;
    }
}
